import { PropsWithChildren } from 'react';
import React, { useEffect } from 'react';
import { useLaunch } from '@tarojs/taro';
import { View } from '@tarojs/components';
import { UserProvider, useUserStore } from './store/user.jsx';
import './app.scss';

function AppContent({ children }: PropsWithChildren<any>) {
  const store = useUserStore();
  useEffect(() => {
    // 刷新页面后重新加载本地数据
    store.reload();
  }, []);
  return <View>{children}</View>;
}

function App({ children }: PropsWithChildren<any>) {
  useLaunch(() => {
    console.log('App launched.');
  });
  return (
    <UserProvider>
      <AppContent>{children}</AppContent>
    </UserProvider>
  );
}

export default App;
